<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>js压缩图片</title>
</head>
<!-- https://mp.weixin.qq.com/s?__biz=MzIyNDU2NTc5Mw==&mid=2247488185&idx=1&sn=06aeb17bd794744820281c470ea5fca6&chksm=e80c5df7df7bd4e1b32c0de8511a38729608a786196ec7df6fd78a45a8552fd6253ff86ec8b4&scene=126&sessionid=1607733977&key=3c9189d1b71985a558e3ea956e990fb5f2b405ce4db358acd2c8cb7576e39d9b4574ff84244d30dd925dc057d0e5a2cd1ace87bcb95abec0a1ccd1d9a7bf6b76cab4878890e9b8e8b869f93ea35b9517138e5907c7f37486711466942232bc4d9e1006c2e57105217f2475ca4ff961227453dde23c0cc737b79e3b7c9d90edb5&ascene=1&uin=NzU0OTY0Mzk5&devicetype=Windows+10+x64&version=6300002f&lang=zh_CN&exportkey=Ayd5OAnM3%2B9eeP7wyktBZQw%3D&pass_ticket=izJ%2FCkdbHOtb2mCsdnnK1S6aq6WClBgE9cm3y5C2Jby1d0n0AECQeaambkADguGM&wx_header=0 -->

<body>
  <input type="file" value="图片压缩" id="file">
</body>
<script>
  "use strict"; {
    const file = document.getElementById("file");
    file.addEventListener("click", async (e) => {
      const reader = new FileReader();
      reader.onload = function () {
        callback(reader.result);
      };
      reader.readAsDataURL(file);
    });
  };
</script>

</html>